<?php


/**
 * Radcodes - SocialEngine Module
 *
 * @category   Application_Extensions
 * @package    Cmspage
 * @copyright  Copyright (c) 2009-2010 Radcodes LLC (http://www.radcodes.com)
 * @license    http://www.radcodes.com/license/
 * @version    $Id$
 * @author     Vincent Van <vincent@radcodes.com>
 */
 
 
?>

<script type="text/javascript">
  var categoryAction =function(category){
    $('category').value = category;
    $('filter_form').submit();
  }
  var tagAction =function(tag){
    $('tag').value = tag;
    $('filter_form').submit();
  }

</script>

<div class="headline">
  <h2>
    <?php echo $this->translate('Pages3');?>
  </h2>
  <div class="tabs">
    <?php
      // Render the menu
      echo $this->navigation()
        ->menu()
        ->setContainer($this->navigation)
        ->render();
    ?>
  </div>
</div>


<div class='layout_right'>
  <?php echo $this->form->render($this) ?>
  <?php if( $this->can_create): ?>
      <div class="quicklinks">
        <ul>
          <li>
            <a href='<?php echo $this->url(array(), 'cmspage_create', true) ?>' class='buttonlink icon_cmspage_new'><?php echo $this->translate('Post New Page');?></a>
          </li>
        </ul>
      </div>
  <?php endif; ?>
</div>

<div class='layout_middle'>
  <?php if ($this->current_count >= $this->quota  && $this->quota > 0):?>
    <div class="tip">
      <span>
        <?php echo $this->translate('You have already created the maximum number of pages allowed. If you would like to create a new page, please delete an old one first.');?>
      </span>
    </div>
    <br/>
  <?php endif; ?>

  <?php if( $this->paginator->getTotalItemCount() > 0 ): ?>
	  <div class="cmspages_list">
	    <ul>
	      <?php foreach( $this->paginator as $item ): ?>
	        <li>
            <div class="cmspages_list_info">
              <p class="cmspages_list_info_title">
                <?php if (!$item->isPublished()): ?>
                  <span class="cmspage_draft_tip"><?php echo $this->translate('[Draft]'); ?></span>
                <?php endif; ?>  

                <?php echo $this->htmlLink($item->getHref(), $item->getTitle()) ?>
                <?php if( $item->featured ): ?>
                  <img src='application/modules/Cmspage/externals/images/featured.png' class='cmspage_title_icon_featured' />
                <?php endif;?>
                <?php if( $item->sticky ): ?>
                  <img src='application/modules/Cmspage/externals/images/sticky.png' class='cmspage_title_icon_sticky' />
                <?php endif;?>
              </p>
              <p class="cmspages_list_info_description"><?php echo $this->viewMore($item->getDescription())?></p>
            </div>
            <div class="cmspages_list_meta">
              <p class="cmspages_list_meta_category">
                <?php if ($category = $item->getCategory()): ?>
                  <?php echo $this->htmlLink(array('route' => 'cmspage_browse', 'category' => $category->category_id), $this->translate($category->category_name)); ?>
                <?php endif;?>
              </p>
              <p class="cmspages_list_meta_date"><?php echo $this->timestamp(strtotime($item->creation_date)) ?></p>
              <p class="cmspages_list_meta_stats">
                <?php echo $this->translate(array("%s view", "%s views", $item->view_count), $item->view_count); ?>
                <?php if ($item->comment_count): ?>
                  - <?php echo $this->translate(array("%s comment", "%s comments", $item->comment_count), $item->comment_count); ?>
                <?php endif; ?>
              </p>
            </div>
            <div class='cmspages_list_actions'>
              <?php if ($this->can_edit): ?>
                <a href='<?php echo $this->url(array('cmspage_id' => $item->cmspage_id), 'cmspage_edit', true) ?>' class='buttonlink icon_cmspage_edit'><?php echo $this->translate('Edit Page');?></a>  
              <?php endif; ?>
              <?php if( $this->allowed_upload ): ?>
                <?php echo $this->htmlLink(array(
                    'route' => 'cmspage_extended',
                    'controller' => 'photo',
                    'action' => 'upload',
                    'subject' => $item->getGuid(),
                  ), $this->translate('Add Photos'), array(
                    'class' => 'buttonlink icon_cmspage_photo_new'
                )) ?>
              <?php endif; ?>
              <?php if ($this->can_delete): ?>
                <a href='<?php echo $this->url(array('cmspage_id' => $item->cmspage_id), 'cmspage_delete', true) ?>' class='buttonlink icon_cmspage_delete'><?php echo $this->translate('Delete Page');?></a>
              <?php endif; ?>
            </div>  
	        </li>
	      <?php endforeach; ?>
	    </ul>
	  </div>
  <?php elseif($this->search): ?>
    <div class="tip">
      <span>
        <?php echo $this->translate('You do not have any pages that match your search criteria.');?>
      </span>
    </div>
  <?php else:?>
    <div class="tip">
      <span>
        <?php echo $this->translate('You do not have any pages.');?>
        <?php if ($this->can_create): ?>
          <?php echo $this->translate('Get started by <a href=\'%1$s\'>posting</a> a new page.', $this->url(array(), 'cmspage_create'));?>
        <?php endif; ?>
      </span>
    </div>
  <?php endif; ?>

    <?php echo $this->paginationControl($this->paginator, null, null, array(
      'query' => $this->formValues
    )); ?>    
    
  
</div>   
